package com.uh.microservice.core.spring.di;

import akka.actor.Extension;
import akka.actor.Props;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

/**
 * spring的扩展
 * Created by liming on 2017/9/15.
 */
@Component("SpringExtension")
public class SpringExtension implements Extension {
    private ApplicationContext applicationContext;

    /**
     *  初始化方法
     */
    public void initialize(ApplicationContext applicationContext) {
        this.applicationContext=applicationContext;
    }

    /**
     *  通过名称获取属性
     */
    public Props props(String actorBeanName){
        return Props.create(SpringActorProducer.class,applicationContext,actorBeanName);
    }

    /**
     *  通过名称和参数获取属性
     */
    public Props props(String actorBeanName, Object... args) {
        return Props.create(SpringActorProducer.class, applicationContext, actorBeanName, args);
    }
}
